<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page session="true"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/resources/css/jquery.mobile-1.4.2.min.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/resources/css/app.css?v=0.2.11">
<script
	src="${pageContext.request.contextPath}/resources/js/jquery-1.11.0.min.js"></script>
<script
	src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCP-0bSxwoVNwRjCnRIWYwFauJ0sNctxI0&sensor=false&libraries=places"></script>
<script
	src="${pageContext.request.contextPath}/resources/js/views/form_registrar_propiedad.js"></script>
<script
	src="${pageContext.request.contextPath}/resources/js/jquery.mobile-1.4.2.min.js"></script>
<script
	src="${pageContext.request.contextPath}/resources/js/jquery.validate.js"></script>
<script
	src="${pageContext.request.contextPath}/resources/js/additional-methods.min.js"></script>
<script
	src="${pageContext.request.contextPath}/resources/js/validations.js?v=0.2.11"></script>
<script
	src="${pageContext.request.contextPath}/resources/js/views/form_propiedad.js"></script> 
<script
	src="${pageContext.request.contextPath}/resources/js/views/form_persona.js"></script>
<script>
	$.mobile.ignoreContentEnabled = false
</script>


<style>
.error {
	font-family: calibri;
	font-size: 18px;
	color: red;
	font-size: 18px;
}

#map-canvas {
	height: 100%;
	margin: 0px;
	padding: 0px
}

.controls {
	margin-top: 16px;
	border: 1px solid transparent;
	border-radius: 2px 0 0 2px;
	box-sizing: border-box;
	-moz-box-sizing: border-box;
	height: 32px;
	outline: none;
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

#direccion {
	background-color: #fff;
	padding: 0 11px 0 13px;
	width: 400px;
	font-family: Roboto;
	font-size: 15px;
	font-weight: 300;
	text-overflow: ellipsis;
}

#direccion:focus {
	border-color: #4d90fe;
	margin-left: -1px;
	padding-left: 14px; /* Regular padding-left + 1. */
	width: 401px;
}

.pac-container {
	font-family: Roboto;
}

#type-selector {
	color: #fff;
	background-color: #4d90fe;
	padding: 5px 11px 0px 11px;
}

#type-selector label {
	font-family: Roboto;
	font-size: 13px;
	font-weight: 300;
}
}
</style>
<title>Ingreso de personas</title>
</head>

<body>
	<div id="form" data-role="page" data-ajax="false" data-theme="a">
		<div data-role="header">
			<h1>Registrar Propiedad</h1>
			<c:if test="${sessionScope.rol==1}">
				<a data-iconpos="notext" data-icon="home"
					href="${pageContext.request.contextPath}/index_gerente"></a>
			</c:if>
			<c:if test="${sessionScope.rol==2}">
				<a data-iconpos="notext" data-icon="home"
					href="${pageContext.request.contextPath}/index_agente"></a>
			</c:if>
		</div>
		<div role="main" class="ui.content">
			<div class="centered-content">
				<form:form action="registrar_propiedad" method="POST" id="f"
					data-ajax="false">
					<table class="outputTable">
						<%-- <tr>
							<td>Número(*):</td>
							<td><form:input path="numero" />
								<p class="error" id="errors" style="display: none;">El
									número ya esta registrado</p></td>
						</tr> --%>
						<tr>
							<td>Rut Propietario(*):</td>
							<td class="multi-td"><form:input id="propietario"
									path="propietario.rut"
									onblur="doSearch('${pageContext.request.contextPath}/search_persona',this,1)" />
								<a href="#poalopupDig" data-iconpos="notext" data-icon="plus"
								data-role="button" data-rel="popup" data-position-to="window"
								style="float: left; display: inline-block;"
								onclick="$('#target').val('#propietario');clearPersona(true);"
								data-transition="pop"> +</a></td>
						</tr>
						<tr style="display: none" id="p-1">
							<td colspan="2">
								<table class="inner" id="tp-1" style="display: none">
									<tr>
										<td>Nombre :</td>
										<td class="nombre"></td>
									</tr>
									<tr>
										<td>Dirección :</td>
										<td class="direccion"></td>
									</tr>
									<tr>
										<td>Comuna :</td>
										<td class="comuna"></td>
									</tr>

								</table>
								<p class="error" id="error-1">El propietario indicado no
									esta registrado</p>


							</td>
						</tr>
						<tr>
							<td>Agente Responsable:</td>
							<td><form:select path="agente.id" items="${listaAgentes}"
									itemValue="id" itemLabel="persona.nombre">
								</form:select></td>
						</tr>


						<%-- <tr>
							<td>Rut Agente:</td>
							<td><form:input id="agente" path="agente.persona.rut"
									onblur="doSearch('${pageContext.request.contextPath}/search_persona',this,2)" /></td>
						</tr>
						<tr style="display: none" id="p-2">
							<td colspan="2">
								<table class="inner" id="tp-2" style="display: none">
									<tr>
										<td>Nombre</td>
										<td class="nombre"></td>
									</tr>
									<tr>
										<td>Dirección</td>
										<td class="direccion"></td>
									</tr>
									<tr>
										<td>Comuna</td>
										<td class="comuna"></td>
									</tr>
								</table>
								<p class="error" id="error-2">El agente no esta registrado</p>


							</td>
						</tr> --%>
						<%-- <tr class="multi-td">
							<td>Rut Captador:</td>
							<td><form:input id="captador" path="captador.rut"
									onblur="doSearch('${pageContext.request.contextPath}/search_persona',this,3)" />
								<a href="#poalopupDig" data-iconpos="notext" data-icon="plus"
								data-role="button" data-rel="popup" data-position-to="window"
								style="float: left; display: inline-block;"
								onclick="$('#target').val('#captador');clearPersona(true);"
								data-transition="pop"> +</a></td>
						</tr> --%>
						<tr style="display: none" id="p-3">
							<td colspan="2">
								<table class="inner" id="tp-3" style="display: none">
									<tr>
										<td>Nombre</td>
										<td class="nombre"></td>
									</tr>
									<tr>
										<td>Dirección</td>
										<td class="direccion"></td>
									</tr>
									<tr>
										<td>Comuna</td>
										<td class="comuna"></td>
									</tr>

								</table>
								<p class="error" id="error-3">El captador no esta registrado</p>
							</td>
						</tr>
						<tr>
							<td>Tipo de propiedad(*):</td>
							<td><form:select path="tipoPropiedad.id"
									items="${listaprop}" itemValue="id" itemLabel="nombre">
								</form:select></td>
						</tr>
						<tr>
							<td>Venta/Arriendo(*) :</td>
							<td><fieldset data-role="controlgroup"
									data-type="horizontal">
									<form:radiobutton path="venta" id="venta" value="true"
										checked="checked" />
									<label for="venta">Venta</label>
									<form:radiobutton path="venta" id="arriendo" value="false" />
									<label for="arriendo">Arriendo</label>
								</fieldset></td>
						</tr>
						<tr>
							<td>Metros Cuadrados(*):</td>
							<td><form:input type="text" id="metrosCuadrados"
									path="metrosCuadrados" size="23" />&nbsp;&nbsp;</td>
						</tr>
						


						 <tr>
							<td>Comuna(*):</td>
							<td><form:input type="hidden" id="comuna"
									path="comuna.nombre" size="23" /></td>
						</tr>
						<tr>

							<td colspan="2"><div id="map-canvas"
									style="width: 470px; height: 300px;"></div></td>
							<form:input id="direccion" class="controls" path="direccion"
								placeholder="Ingrese la dirección" />
						</tr>
						<tr>
							<td>Valor(*):</td>
							<td class="multi-td"><form:input id="valor" path="valor"
									size="10" />
								<fieldset data-role="controlgroup" data-type="horizontal"
									style="float: left; margin-left: 10px;">
									<form:radiobutton path="valorEnUf" id="radio-choice-h-3a"
										value="true" checked="checked" />
									<label for="radio-choice-h-3a">UF</label>
									<form:radiobutton path="valorEnUf" id="radio-choice-h-3b"
										value="false" />
									<label for="radio-choice-h-3b">Pesos</label>
								</fieldset></td>


						</tr>
						<tr>
							<td>Amoblado(*):</td>
							<td><fieldset data-role="controlgroup"
									data-type="horizontal">
									<form:radiobutton path="amoblada" id="radio-choice-h-2a"
										value="true" checked="checked" />
									<label for="radio-choice-h-2a">Si</label>
									<form:radiobutton path="amoblada" id="radio-choice-h-2b"
										value="false" />
									<label for="radio-choice-h-2b">No</label>
								</fieldset></td>
						</tr>
						<tr>
							<td>Detalle:</td>
							<td><form:textarea id="detalle" path="detalle" size="23"
									rows="3" /></td>
						</tr>
						<tr>
							<c:if test="${sessionScope.rol==1}">
								<td><a
									href="${pageContext.request.contextPath}/index_gerente"
									data-ajax="false"
									class="ui-btn ui-btn-b ui-icon-delete ui-btn-icon-left">Salir
										sin registrar</a></td>
							</c:if>
							<c:if test="${sessionScope.rol==2}">
								<td><a
									href="${pageContext.request.contextPath}/index_agente"
									data-ajax="false"
									class="ui-btn ui-btn-b ui-icon-delete ui-btn-icon-left">Salir
										sin registrar</a></td>
							</c:if>
							<td><button type="submit" data-ajax="false"
									class="ui-btn ui-icon-check ui-btn-icon-right ok">Registrar</button></td>
						</tr>
					</table>
					<form:input type="hidden" path="latitud" id="latitud" />
					<form:input type="hidden" path="longitud" id="longitud" />
					<input type="hidden" id="target">
				</form:form>
			</div>

			<div data-role="popup" data-overlay-theme="b"
				data-dismissible="false" id="poalopupDig">
				<form:form action="registrar_cliente" method="POST"
					id="form_persona">
					<input type="hidden" name="id" id="hid" />
					<table class="outputTable">
						<tr>
							<td>Rut (*):</td>
							<td><input id="rut" name="rut" type='text'
								onblur="doSearchPersona('${pageContext.request.contextPath}/search_persona',this)" /></td>
						</tr>
						<tr>
							<td>Nombre (*):</td>
							<td><input name="nombre" type='text' /></td>
						</tr>
						<tr>

							<td>Direccion (*):</td>
							<td><input name="direccion" type='text' /></td>
						</tr>
						<tr>
							<td>Comuna :</td>
							<td><form:select path="comuna.id" items="${listaComunas}"
									itemValue="id" itemLabel="nombre">
								</form:select></td>
						</tr>
						<tr>
							<td>Ciudad (*):</td>
							<td><input name="ciudad" type='text' /></td>
						</tr>
						<tr>
							<td>Contacto :</td>
							<td><input name="contacto" type='text' /></td>
						</tr>
						<tr>
							<td>Fono Casa :</td>
							<td><input name="fonoCasa" type='text' /></td>
						</tr>
						<tr>
							<td>Fono Oficina :</td>
							<td><input name="fonoOficina" type='text' /></td>
						</tr>

						<tr>
							<td>Fono Movil:</td>
							<td><input name="fonoMovil" type='text' /></td>
						</tr>

						<tr>
							<td>Correo(*):</td>
							<td><input name="correo" type='text' /></td>
						</tr>
						<tr>
							<td>Observaciones :</td>
							<td><textarea name="observaciones" rows="3"></textarea></td>
						</tr>
						<tr>
							<td><a
								href="${pageContext.request.contextPath}/index_gerente"
								class="ui-btn ui-btn-b ui-icon-delete ui-btn-icon-left"
								onclick="$('#poalopupDig').popup( 'close' );return false;">Cancelar</a></td>
						
							<td><a href="#"
								onclick="ajaxSend('${pageContext.request.contextPath}/registrar_comprador',$('#target').val());$('#poalopupDig').popup( 'close' );return false;"
								class="ui-btn ui-icon-check ui-btn-icon-right">Registrar</a></td>
						</tr>
					</table>
				</form:form>
			</div>
		</div>

	</div>


</body>
</html>